package com.tekj.cxqcb.view.Module.activity.Order;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.entity.LocalMedia;
import com.tekj.cxqcb.R;
import com.tekj.cxqcb.config.enums.EventBusMsgBean;
import com.tekj.cxqcb.operation.BusinessDao;
import com.tekj.cxqcb.operation.resultBean.PubStatusBean;
import com.tekj.cxqcb.operation.resultBean.UploadFiles;
import com.tekj.cxqcb.view.Module.adapter.Proposal2Adapter;
import com.tekj.cxqcb.view.Module.bean.ImageBean;
import com.tekj.cxqcb.view.Module.bean.NewOrderBean;
import com.tekj.cxqcb.view.Module.decoration.SpacesItemDecoration;

import org.greenrobot.eventbus.EventBus;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import common.base.activity.BaseActivity;
import common.base.operationHelper.Bean.BindingViewBean;
import common.tool.Tools;
import common.widget.ZoomImageView;
import es.dmoral.toasty.Toasty;

import static com.tekj.cxqcb.config.enums.EventBusMsgBean.EnumStatus.订单关闭;
import static com.tekj.cxqcb.view.Module.activity.Order.CarOrderDetailsActivity.orderData;
import static com.tekj.cxqcb.view.Module.activity.Order.ContractInformationActivity.getImges;
import static com.tekj.cxqcb.view.Module.activity.Order.NewOrdersActivity.isModify;
import static com.tekj.cxqcb.view.Module.activity.Order.NewOrdersActivity.orderType;
import static com.tekj.cxqcb.view.Module.activity.Order.NewOrdersActivity.shopname;

/**
 * 新增订单第二页
 */
public class NewOrdersTwoActivity extends BaseActivity {
    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.tv_l)
    TextView tvL;
    @BindView(R.id.ll_back)
    LinearLayout llBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_r)
    ImageView ivR;
    @BindView(R.id.tv_r)
    TextView tvR;
    @BindView(R.id.ll_right)
    LinearLayout llRight;
    @BindView(R.id.rl_title_bg)
    RelativeLayout rlTitleBg;
    @BindView(R.id.tv_khlx)
    TextView tvKhlx;
    @BindView(R.id.tv_ch)
    TextView tvCh;
    @BindView(R.id.et_phone)
    EditText etPhone;
    @BindView(R.id.tv_zjlx)
    TextView tvZjlx;
    @BindView(R.id.et_zjhm)
    EditText etZjhm;
    @BindView(R.id.et_name)
    EditText etName;
    @BindView(R.id.tv_hmd)
    TextView tvHmd;
    @BindView(R.id.tv_sl1)
    TextView tvSl1;
    @BindView(R.id.tv_sl2)
    TextView tvSl2;
    @BindView(R.id.tv_sl3)
    TextView tvSl3;
    @BindView(R.id.tv_sl4)
    TextView tvSl4;
    @BindView(R.id.tv_sl5)
    TextView tvSl5;
    @BindView(R.id.tv_sl6)
    TextView tvSl6;
    @BindView(R.id.rv_sqb)
    RecyclerView rvSqb;
    @BindView(R.id.tv_sl7)
    TextView tvSl7;
    @BindView(R.id.tv_sl8)
    TextView tvSl8;
    @BindView(R.id.rv_zxzl)
    RecyclerView rvZxzl;
    @BindView(R.id.rv_qtzl)
    RecyclerView rvQtzl;
    @BindView(R.id.et_remark)
    EditText etRemark;
    @BindView(R.id.tv_submission)
    TextView tvSubmission;
    @BindView(R.id.rv_jsz)
    RecyclerView rvJsz;
    @BindView(R.id.rv_zxmqz)
    RecyclerView rvZxmqz;
    @BindView(R.id.rv_yhk)
    RecyclerView rvYhk;
    @BindView(R.id.rv_zxsqjt)
    RecyclerView rvZxsqjt;
    @BindView(R.id.ll_type1)
    LinearLayout llType1;
    @BindView(R.id.rv_sfz_z)
    RecyclerView rvSfzZ;
    @BindView(R.id.rv_sfz_f)
    RecyclerView rvSfzF;

    private BusinessDao businessDao;

    private Proposal2Adapter adapter, adapter2, adapter3,
            adapter4, adapter5, adapter6,
            adapter7, adapter8, adapter9;

    private List<LocalMedia> localMedias, localMedias2, localMedias3,
            localMedias4, localMedias5, localMedias6,
            localMedias7, localMedias8, localMedias9;

    private List<ImageBean> imgs1, imgs2, imgs3,
            imgs4, imgs5, imgs6,
            imgs7, imgs8, imgs9;

    private NewOrderBean newOrderBean;

    private String urls[] = {
            "https://apk.cars-cxqc.com/%E7%A4%BA%E4%BE%8B%E5%9B%BE_%E8%BA%AB%E4%BB%BD%E8%AF%81%E6%AD%A3%E9%9D%A2.jpg",//身份证正
            "https://apk.cars-cxqc.com/%E7%A4%BA%E4%BE%8B%E5%9B%BE_%E8%BA%AB%E4%BB%BD%E8%AF%81%E6%AD%A3%E5%8F%8D%E9%9D%A2.jpg", //身份证反
            "https://apk.cars-cxqc.com/%E7%A4%BA%E4%BE%8B%E5%9B%BE_%E9%93%B6%E8%A1%8C%E5%8D%A1.jpg",//*银行卡
            "https://apk.cars-cxqc.com/%E7%A4%BA%E4%BE%8B%E5%9B%BE_%E9%A9%BE%E9%A9%B6%E8%AF%81.jpg",//驾驶证
            "https://apk.cars-cxqc.com/%E7%A4%BA%E4%BE%8B%E5%9B%BE_%E5%BE%81%E4%BF%A1%E6%8E%88%E6%9D%83%E6%88%AA%E5%9B%BE.jpg",//征信授权截图
            "https://apk.cars-cxqc.com/%E7%A4%BA%E4%BE%8B%E5%9B%BE_%E5%BE%81%E4%BF%A1%E6%8E%88%E6%9D%83%E6%88%AA%E5%9B%BE.jpg",//征信面签照
            "https://apk.cars-cxqc.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20190810135821.jpg",//申请表
            "https://apk.cars-cxqc.com/%E7%A4%BA%E4%BE%8B%E5%9B%BE_%E5%BE%81%E4%BF%A1%E6%8E%88%E6%9D%83%E4%B9%A6.jpg",//征信资料
    };

    @Override
    public void init() {
        tvTitle.setText(orderType == 1 ? "修改进件信息" : "新建订单");
        newOrderBean = (NewOrderBean) getIntent().getSerializableExtra("bean");
        businessDao = new BusinessDao(activity, this);
        tvCh.setText(shopname);
        initList();
        if (orderType == 1) {
            setData();
        }


    }

    /**
     * 初始化List，adapter
     */
    public void initList() {
        localMedias = new ArrayList<>();
        localMedias2 = new ArrayList<>();
        localMedias3 = new ArrayList<>();
        localMedias4 = new ArrayList<>();
        localMedias5 = new ArrayList<>();
        localMedias6 = new ArrayList<>();
        localMedias7 = new ArrayList<>();
        localMedias8 = new ArrayList<>();
        localMedias9 = new ArrayList<>();

        imgs1 = new ArrayList<>();
        imgs2 = new ArrayList<>();
        imgs3 = new ArrayList<>();
        imgs4 = new ArrayList<>();
        imgs5 = new ArrayList<>();
        imgs6 = new ArrayList<>();
        imgs7 = new ArrayList<>();
        imgs8 = new ArrayList<>();
        imgs9 = new ArrayList<>();

        if (orderType == 1) {
            if (orderData.getOrder().getZxmqz() != null) {
                getImges(orderData.getOrder().getZxmqz(), imgs1, localMedias);
            }
            if (orderData.getOrder().getJsz() != null) {
                getImges(orderData.getOrder().getJsz(), imgs2, localMedias2);
            }
            if (orderData.getOrder().getSfzzm() != null) {
                getImges(orderData.getOrder().getSfzzm(), imgs3, localMedias3);
            }

            if (orderData.getOrder().getSfzfm() != null) {
                getImges(orderData.getOrder().getSfzfm(), imgs4, localMedias4);
            }
            if (orderData.getOrder().getZxmqz() != null) {
                getImges(orderData.getOrder().getZxmqz(), imgs5, localMedias5);
            }
            if (orderData.getOrder().getSqb() != null) {
                getImges(orderData.getOrder().getSqb(), imgs6, localMedias6);
            }
            if (orderData.getOrder().getYhk() != null) {
                getImges(orderData.getOrder().getYhk(), imgs7, localMedias7);
            }
            if (orderData.getOrder().getZxzl() != null) {
                getImges(orderData.getOrder().getZxzl(), imgs8, localMedias8);
            }
            if (orderData.getOrder().getQtzl() != null) {
                getImges(orderData.getOrder().getQtzl(), imgs9, localMedias9);
            }

        }

        adapter = new Proposal2Adapter(activity, localMedias, isModify());
        adapter2 = new Proposal2Adapter(activity, localMedias2, isModify());
        adapter3 = new Proposal2Adapter(activity, localMedias3, isModify());
        adapter4 = new Proposal2Adapter(activity, localMedias4, isModify());
        adapter5 = new Proposal2Adapter(activity, localMedias5, isModify());
        adapter6 = new Proposal2Adapter(activity, localMedias6, isModify());
        adapter7 = new Proposal2Adapter(activity, localMedias7, isModify());
        adapter8 = new Proposal2Adapter(activity, localMedias8, isModify());
        adapter9 = new Proposal2Adapter(activity, localMedias9, isModify());


        initAdaper(adapter, localMedias, rvZxsqjt, imgs1, 1001);
        initAdaper(adapter2, localMedias2, rvJsz, imgs2, 1002);
        initAdaper(adapter3, localMedias3, rvSfzZ, imgs3, 1003);
        initAdaper(adapter4, localMedias4, rvSfzF, imgs4, 1004);
        initAdaper(adapter5, localMedias5, rvZxmqz, imgs5, 1005);
        initAdaper(adapter6, localMedias6, rvSqb, imgs6, 1006);
        initAdaper(adapter7, localMedias7, rvYhk, imgs7, 1007);
        initAdaper(adapter8, localMedias8, rvZxzl, imgs8, 1008);
        initAdaper(adapter9, localMedias9, rvQtzl, imgs9, 1009);

    }

    public void initAdaper(final Proposal2Adapter adapter, final List<LocalMedia> localMedias,
                           RecyclerView recyclerView, final List<ImageBean> imgs, final int code) {


        adapter.setOnCallbackListener(new Proposal2Adapter.OnCallbackListener() {
            @Override
            public void onAddPhotoClick() {
                if (isModify())
                    //添加图片
                    Tools.InitPictureSelector(activity, false, code,
                            getLocalMedias(localMedias), 9 - localMedias.size());
            }

            @Override
            public void onPicturePreview(int position) {
                //图片预览
//                PictureSelector.create(activity).externalPicturePreview(position, localMedias);
            }

            @Override
            public void onPictureDelete(int position) {
                localMedias.remove(position);
                imgs.remove(position);
                adapter.setList(localMedias, localMedias.size() + 1);
            }
        });

        recyclerView.setLayoutManager(new GridLayoutManager(activity, 3));
        recyclerView.setHasFixedSize(true);
        recyclerView.setAdapter(adapter);
        recyclerView.addItemDecoration(new SpacesItemDecoration(10));
    }

    @Override
    public int setLayout() {
        return R.layout.activity_new_orders_two;
    }

    @Override
    public void initLoadStart() {

    }

    @Override
    public void initLoadEnd() {

    }

    @Override
    public void initBindingView(Object mBean) {
        BindingViewBean bindingViewBean = (BindingViewBean) mBean;
        switch (bindingViewBean.getmEnumStatus()) {
            case 多文件上传:
                UploadFiles uploadFiles = (UploadFiles) bindingViewBean.getBean();
                if (!uploadFiles.getCode().equals("0000000")) {
                    Toasty.normal(activity, uploadFiles.getMsg()).show();
                    return;
                }
                if (uploadFiles.getTypeName().equals("驾驶证")) {
                    addImg(uploadFiles, imgs2);
                } else if (uploadFiles.getTypeName().equals("征信面签照")) {
                    addImg(uploadFiles, imgs5);
                } else if (uploadFiles.getTypeName().equals("银行卡")) {
                    addImg(uploadFiles, imgs7);
                } else if (uploadFiles.getTypeName().equals("征信授权截图")) {
                    addImg(uploadFiles, imgs1);
                } else if (uploadFiles.getTypeName().equals("征信资料")) {
                    addImg(uploadFiles, imgs8);
                } else if (uploadFiles.getTypeName().equals("申请表")) {
                    addImg(uploadFiles, imgs6);
                } else if (uploadFiles.getTypeName().equals("身份证正面")) {
                    addImg(uploadFiles, imgs3);
                } else if (uploadFiles.getTypeName().equals("身份证反面")) {
                    addImg(uploadFiles, imgs4);
                } else if (uploadFiles.getTypeName().equals("其他资料")) {
                    addImg(uploadFiles, imgs9);
                }

                break;
            case 购车订单新增:

                PubStatusBean pubStatusBean = (PubStatusBean) bindingViewBean.getBean();
                if (pubStatusBean.getCode().equals("0000000")) {
                    EventBus.getDefault().post(new EventBusMsgBean(订单关闭, ""));
                    finish();
                }
                Toasty.normal(activity, pubStatusBean.getMsg()).show();
                break;
        }
    }


    @OnClick({R.id.ll_back, R.id.tv_khlx, R.id.tv_ch, R.id.tv_zjlx,
            R.id.tv_hmd, R.id.tv_sl1, R.id.tv_sl2,
            R.id.tv_sl3, R.id.tv_sl4, R.id.tv_sl5,
            R.id.tv_sl6, R.id.tv_sl7, R.id.tv_sl8,
            R.id.rv_qtzl, R.id.tv_submission, R.id.tv_xz2,
            R.id.tv_xz1,
    })
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_back:
                finish();
                break;
            case R.id.tv_khlx:
                break;
            case R.id.tv_ch:
                break;
            case R.id.tv_zjlx:
                break;
            case R.id.tv_hmd:
                break;
            case R.id.tv_xz2:
                Tools.showNormalDialogOne(activity, "征信资料", "复制征信资料链接", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        CopyUrls("https://apk.cars-cxqc.com/5.%E5%BE%81%E4%BF%A1%E6%8E%88%E6%9D%83%E4%B9%A6%EF%BC%88%E4%B8%AA%E4%BA%BA%EF%BC%89%E5%B9%B3%E5%AE%89%E6%96%B0%E7%89%88.pdf");
                        Toasty.normal(activity, "已复制,请去浏览器中下载").show();
                    }
                }, null);
                break;
            case R.id.tv_xz1:
                Tools.showNormalDialogOne(activity, "申请表", "复制申请表链接", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        CopyUrls("https://apk.cars-cxqc.com/1.%E4%B9%98%E7%94%A8%E8%BD%A6%E7%94%B3%E8%AF%B7%E8%A1%A8%EF%BC%88%E4%B8%AA%E4%BA%BA%EF%BC%89%E5%B9%B3%E5%AE%89%E6%96%B0%E7%89%88.pdf");
                        Toasty.normal(activity, "已复制,请去浏览器中下载").show();
                    }
                }, null);

                break;
            case R.id.tv_sl1:
                //TODO 征信授权图
                showPop(urls[4]);
                break;
            case R.id.tv_sl2:
                //TODO 驾驶证
                showPop(urls[3]);
                break;
            case R.id.tv_sl3:
                //TODO 身份证正面
                showPop(urls[0]);
                break;
            case R.id.tv_sl4:
                //TODO 身份证反面
                showPop(urls[1]);
                break;
            case R.id.tv_sl5:
                showPop(urls[5]);
                break;
            case R.id.tv_sl6:
                //TODO 申请表
                showPop(urls[6]);
                break;
            case R.id.tv_sl7:
                //TODO 银行卡
                showPop(urls[2]);
                break;
            case R.id.tv_sl8:
                //TODO 征信资料
                showPop(urls[7]);
                break;
            case R.id.tv_submission:
                if (!isModify()) {
                    Toasty.normal(activity, "进件信息未审核或已通过").show();
                    return;
                }
                Tools.showNormalDialogOne(activity, "订单提交", "是否提交？", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        UpData();
                    }
                }, null);

                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        List<LocalMedia> lists;
        List<File> list = new ArrayList<>();
        if (resultCode == RESULT_OK) {
            lists = PictureSelector.obtainMultipleResult(data);
            switch (requestCode) {
                case 1001:
                    upImg(lists, list, localMedias, adapter, "征信授权截图");
                    break;
                case 1002:
                    upImg(lists, list, localMedias2, adapter2, "驾驶证");
                    break;
                case 1003:
                    upImg(lists, list, localMedias3, adapter3, "身份证正面");
                    break;
                case 1004:
                    upImg(lists, list, localMedias4, adapter4, "身份证反面");
                    break;
                case 1005:
                    upImg(lists, list, localMedias5, adapter5, "征信面签照");
                    break;
                case 1006:
                    upImg(lists, list, localMedias6, adapter6, "申请表");
                    break;
                case 1007:
                    upImg(lists, list, localMedias7, adapter7, "银行卡");
                    break;
                case 1008:
                    upImg(lists, list, localMedias8, adapter8, "征信资料");
                    break;
                case 1009:
                    upImg(lists, list, localMedias9, adapter9, "其他资料");
                    break;
            }
        }
    }

    private PopupWindow popupWindow;
    private View popupView;
    private TranslateAnimation animation;

    /**
     * 提示图片
     *
     * @param url
     */
    private void showPop(String url) {
        Tools.lightoff(activity);
        popupView = View.inflate(activity, R.layout.pop_help_img, null);
        popupWindow = new PopupWindow(popupView, LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT, true);

        popupWindow.setBackgroundDrawable(new BitmapDrawable());
        popupWindow.setFocusable(true);
        popupWindow.setOutsideTouchable(true);


        animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0,
                Animation.RELATIVE_TO_PARENT, -1, Animation.RELATIVE_TO_PARENT, 0);
        animation.setInterpolator(new AccelerateInterpolator());
        animation.setDuration(200);

        LinearLayout linearLayout = popupView.findViewById(R.id.ll_back);
        linearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popupWindow.dismiss();
            }
        });

        ZoomImageView imageView = popupView.findViewById(R.id.img_help);
        Tools.picassoNetwork(url, imageView);

        popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                Tools.lighton(activity);
            }
        });

        popupWindow.showAtLocation(tvTitle, Gravity.CENTER, 0, 0);
        popupView.startAnimation(animation);

    }


    /**
     * 获取除已上传图片（新增的本地图片）
     *
     * @return
     */
    List<LocalMedia> getLocalMedias(List<LocalMedia> localMedias) {
        List<LocalMedia> list = new ArrayList<>();
        for (int i = 0; i < localMedias.size(); i++) {
            if (!localMedias.get(i).getCompressPath().startsWith("http")) {
                list.add(localMedias.get(i));
            }
        }
        return list;
    }

    /**
     * 添加图片
     *
     * @param data
     */
    void addLocalMedias(List<LocalMedia> data, List<LocalMedia> localMedias) {
        boolean isadd;
        for (int i = 0; i < data.size(); i++) {
            isadd = true;
            for (int j = 0; j < localMedias.size(); j++) {
                if (localMedias.get(j).getCompressPath().equals(data.get(i).getCompressPath())) {
                    isadd = false;
                }
            }
            if (isadd)
                localMedias.add(data.get(i));
        }

    }

    /**
     * @param uploadFiles
     * @param imgs
     */
    void addImg(UploadFiles uploadFiles, List<ImageBean> imgs) {
        if (imgs == null) {
            return;
        }
        String[] files = uploadFiles.getData().getUploadFilePath().split(",");
        Iterator it = imgs.iterator();
        while (it.hasNext()) {
            ImageBean m = (ImageBean) it.next();
            if (!m.isInitial()) {
                it.remove();
            }
        }
        for (int i = 0; i < files.length; i++) {
            imgs.add(new ImageBean(files[i], false));
        }
    }

    /**
     * 记录上传的地址
     *
     * @param lists
     * @param list
     * @param localMedias
     * @param adapter
     * @param typename
     */
    void upImg(List<LocalMedia> lists, List<File> list,
               List<LocalMedia> localMedias, Proposal2Adapter adapter,
               String typename) {
        for (int i = 0; i < lists.size(); i++) {
            if (lists.get(i) != null && !lists.get(i).getCompressPath().equals("")) {
                list.add(new File(lists.get(i).getCompressPath()));
            }
        }
        businessDao.uploadFiles(list, typename);
        addLocalMedias(lists, localMedias);
        adapter.setList(localMedias, localMedias.size() < 9 ? localMedias.size() + 1 : 9);
    }

    /**
     * 上传新建订单
     */
    void UpData() {
        if (etPhone.getText().toString().trim().equals("") ||
                etName.getText().toString().trim().equals("") ||
                etZjhm.getText().toString().trim().equals("")) {
            Toasty.normal(activity, "请先填写用户信息").show();
            return;
        }
        if (imgs1.size() == 0 || imgs2.size() == 0 || imgs3.size() == 0 ||
                imgs4.size() == 0 || imgs5.size() == 0 || imgs6.size() == 0 ||
                imgs7.size() == 0 || imgs8.size() == 0) {
            Toasty.normal(activity, "请先上传所需图片").show();
            return;
        }

        newOrderBean.setUserName(etName.getText().toString());
        newOrderBean.setUserPhone(etPhone.getText().toString());
        newOrderBean.setIdcard(etZjhm.getText().toString());
        newOrderBean.setRemark(etRemark.getText().toString());

        newOrderBean.setSfzzm(ImgString(imgs3));
        newOrderBean.setSfzfm(ImgString(imgs4));
        newOrderBean.setYhk(ImgString(imgs7));
        newOrderBean.setJsz(ImgString(imgs2));

        newOrderBean.setZxmqz(ImgString(imgs5));

        newOrderBean.setZxsqjt(ImgString(imgs1));
        newOrderBean.setSqb(ImgString(imgs6));
        newOrderBean.setZxzl(ImgString(imgs8));
        newOrderBean.setQtzl(ImgString(imgs9));

        newOrderBean.setRemark(etRemark.getText().toString().trim());


        if (orderType == 1) {
//            newOrderBean.setDetailId(orderData.getDetail().getId());
            businessDao.UpdateIntoContract(newOrderBean);
        } else {
            businessDao.InsertOrder(newOrderBean);
        }

    }


    public static String ImgString(List<ImageBean> imgs) {
        String imgString = "";
        for (int i = 0; i < imgs.size(); i++) {
            imgString = imgString + (i == 0 ? imgs.get(i).getName() : "," + imgs.get(i).getName());
        }

        return imgString;
    }

    void setData() {
        etName.setText(orderData.getOrder().getUserName());
        etPhone.setText(orderData.getOrder().getUserPhone());
        etZjhm.setText(orderData.getOrder().getIdcard());
        etRemark.setText(orderData.getOrder().getRemark());

        if (!isModify()) {
            etName.setEnabled(true);
            etPhone.setEnabled(true);
            etZjhm.setEnabled(true);
            etRemark.setEnabled(true);
            tvSubmission.setBackgroundColor(getResources().getColor(R.color.dividerColor));
        }

    }

    void CopyUrls(String url) {
        //获取剪贴板管理器：
        ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
// 创建普通字符型ClipData
        ClipData mClipData = ClipData.newPlainText("url", url);
// 将ClipData内容放到系统剪贴板里。
        cm.setPrimaryClip(mClipData);
    }

}
